package com.sam.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * Created by Administrator on 2016/5/31.
 */
public class CouponEntity implements Parcelable{

    private int couponValue;
    private String conponName;
    private int atLeastValue;
    private long validStartTime,validEndTime;
    private boolean isUsed = false;

    public CouponEntity(int couponValue, String conponName, int atLeastValue, long validStartTime, long validEndTime) {
        this.couponValue = couponValue;
        this.conponName = conponName;
        this.atLeastValue = atLeastValue;
        this.validStartTime = validStartTime;
        this.validEndTime = validEndTime;
        this.isUsed = false;
    }


    protected CouponEntity(Parcel in) {
        couponValue = in.readInt();
        conponName = in.readString();
        atLeastValue = in.readInt();
        validStartTime = in.readLong();
        validEndTime = in.readLong();
        isUsed = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(couponValue);
        dest.writeString(conponName);
        dest.writeInt(atLeastValue);
        dest.writeLong(validStartTime);
        dest.writeLong(validEndTime);
        dest.writeByte((byte) (isUsed ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<CouponEntity> CREATOR = new Creator<CouponEntity>() {
        @Override
        public CouponEntity createFromParcel(Parcel in) {
            return new CouponEntity(in);
        }

        @Override
        public CouponEntity[] newArray(int size) {
            return new CouponEntity[size];
        }
    };

    public boolean isUsed() {
        return isUsed;
    }

    public void setUsed(boolean used) {
        isUsed = used;
    }

    public int getCouponValue() {
        return couponValue;
    }

    public void setCouponValue(int couponValue) {
        this.couponValue = couponValue;
    }

    public String getCouponName() {
        return conponName;
    }

    public void setConponName(String conponName) {
        this.conponName = conponName;
    }

    public int getAtLeastValue() {
        return atLeastValue;
    }

    public void setAtLeastValue(int atLeastValue) {
        this.atLeastValue = atLeastValue;
    }

    public long getValidStartTime() {
        return validStartTime;
    }

    public void setValidStartTime(long validStartTime) {
        this.validStartTime = validStartTime;
    }

    public long getValidEndTime() {
        return validEndTime;
    }

    public void setValidEndTime(long validEndTime) {
        this.validEndTime = validEndTime;
    }

    @Override
    public String toString() {
        return "CouponEntity{" +
                "couponValue=" + couponValue +
                ", conponName='" + conponName + '\'' +
                ", atLeastValue=" + atLeastValue +
                ", validStartTime=" + validStartTime +
                ", validEndTime=" + validEndTime +
                ", isUsed=" + isUsed +
                '}';
    }

}
